package com.hf.order

import com.hf.constant.OrderLunchConst
import com.hf.security.OrderUserService

class OrderPeriodService {

	OrderUserService orderUserService

	OrderPeriod getCurrentOrderPeriod(List<Date> dates) {
		OrderPeriod orderPeriod = OrderPeriod.findByStartDateAndEndDate(dates[0], dates[1])

		if (!orderPeriod) {
			orderPeriod = new OrderPeriod(isLatest : true, startDate : dates[0], endDate : dates[1], type : OrderLunchConst.curOrderPeriodType)
			orderPeriod.save()

			orderUserService.updateIsPaidFalse()
		}

		return orderPeriod
	}
}
